//
//  ViewController.m
//  YTKExtensionExample
//
//  Created by Jarvis on 2024/5/29.
//

#import "ViewController.h"
#import <YTKExtension.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    YTKRequestExtension *request = [YTKRequestExtension new];
    YTKRequestInterceptor *interceptor1 = [YTKRequestInterceptor interceptorWillStart:^(id  _Nonnull request) {
        NSLog(@"---interceptor1 will start");
    } willStop:^(id  _Nonnull request) {
        NSLog(@"---interceptor1 will stop");
    } didStop:^(id  _Nonnull request) {
        NSLog(@"---interceptor1 did stop");
    }];
    YTKRequestInterceptor *interceptor2 = [YTKRequestInterceptor interceptorWillStart:^(id  _Nonnull request) {
        NSLog(@"---interceptor2 will start");
    } willStop:^(id  _Nonnull request) {
        NSLog(@"---interceptor2 will stop");
    } didStop:^(id  _Nonnull request) {
        NSLog(@"---interceptor2 did stop");
    }];
    request.baseUrl = @"https://www.baidu.com";
    request.requestUrl = @"/";
    request.responseSerializerType = YTKResponseSerializerTypeHTTP;
    request.requestAccessories = @[interceptor1, interceptor2].mutableCopy;
    [request startWithCompletionBlockWithSuccess:^(YTKRequestExtension * _Nonnull request) {
        NSLog(@"---request success");
    } failure:^(YTKRequestExtension * _Nonnull request) {
        NSLog(@"---request failure");
    }];
}


@end
